package jco3.JCoDestination.demo4;

import java.util.Properties;

import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.ext.DestinationDataProvider;
import com.sap.conn.jco.ext.Environment;

public class DestinationProvider {
	private static Properties setProperties() {
		Properties connProps = new Properties();
        connProps.setProperty(DestinationDataProvider.JCO_ASHOST, "test");
        connProps.setProperty(DestinationDataProvider.JCO_SYSNR, "00");
        connProps.setProperty(DestinationDataProvider.JCO_USER, "test");
        connProps.setProperty(DestinationDataProvider.JCO_PASSWD, "test");
        connProps.setProperty(DestinationDataProvider.JCO_CLIENT, "666");
        connProps.setProperty(DestinationDataProvider.JCO_LANG, "EN");
        return connProps;
	}
	
	public static JCoDestination gerDestination() throws JCoException{
		String destName = "SAP_AS";
		Properties props = setProperties();
		DestinationDataProviderImp destDataProvider = new DestinationDataProviderImp();
		destDataProvider.addDestinationProperties(destName, props);
		Environment.registerDestinationDataProvider(destDataProvider);
		JCoDestination dest = JCoDestinationManager.getDestination(destName);
		return dest;
	}
}
